﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Bots.DungeonBuddy.Attributes;
using Bots.DungeonBuddy.Helpers;
using CommonBehaviors.Actions;
using Styx;
using Styx.Helpers;
using Styx.Logic.Pathing;
using Styx.WoWInternals;
using Styx.WoWInternals.WoWObjects;
using TreeSharp;
using Action = TreeSharp.Action;

namespace Bots.DungeonBuddy.Dungeon_Scripts.Classic
{
    class StormwindStockade : Dungeon
    {
        #region Overrides of Dungeon
        public override uint DungeonId
        {
            get { return 12; }
        }

        public override WoWPoint Entrance { get { return new WoWPoint(-8764.035,847.2657,86.97466); } }
        // 46383" name="Randolph Moloch" killOrder="1" optional="false" X="144.6028" Y="2.146715" Z="-25.60624"/>

        #endregion

        [EncounterHandler(46383, "Randolph Moloch", Mode =  CallBehaviorMode.CurrentBoss)]
        public Composite RandolpfMolochEncounter()
        {
            var bossRoom = new WoWPoint(144.6028, 2.146715, -25.60624);
            WoWUnit boss = null;
            return new PrioritySelector(ctx => boss = ctx as WoWUnit,
                new Decorator(ctx => boss == null && StyxWoW.Me.Location.DistanceSqr(bossRoom) < 40*40,
                    new Sequence( // handle vanish.
                        new WaitContinue(7,ctx => StyxWoW.Me.IsActuallyInCombat,new ActionAlwaysSucceed()),
                        new DecoratorContinue(ctx => !ObjectManager.GetObjectsOfType<WoWUnit>().Any(u => u.Entry == 46383),
                            new Action(ctx => BossManager.CurrentBoss.MarkAsDead()))
                        ))
                );
        }
    }
}
